<template>
  <div class="main">
    <li v-for="(item,index) in friendList" :key="index" @click="toChat(item)">
      <div class="icon">
        <img src="../../../assets/img/003.png" alt>
      </div>
      <div class="rightBox">
        <div class="t">
          {{item.nick}}
          <!-- <div class="time">{{item.updateTime}}</div> -->
        </div>
        <div class="b">{{item.txt}}</div>
      </div>
    </li>
  </div>
</template>
<script>
import { send, getIMData } from "../../../im";
import { format } from "../../../utils";
export default {
  name: "friendList",
  data() {
    return {
      friendList: []
    };
  },
  filters: {
    format: function(shijianchuo) {
      var time = new Date(shijianchuo);
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      return y + "-" + m + "-" + d + " " + h + ":" + mm + ":" + s;
    }
  },
  mounted() {
    getIMData(data => {
      data.friends.forEach(i => {
        data.users.forEach(item => {
          if (item.account == i.account) {
            this.friendList.push(item);
          }
        });
      });
    });
  },
  methods: {
    toChat(item) {
      this.$router.push({
        path: "/coze",
        query: { item: JSON.stringify(item) }
      });
    }
  }
};
</script>
<style lang="stylus" scoped>
.main {
  width: 100%;
  background: #FFF;

  li {
    width: 6.84rem;
    border-bottom: 1px solid #E6E6E6;
    margin: 0 auto;
    display: flex;

    .icon {
      width: 1.29rem;
      height: 1.31rem;
      margin: 10px 0;
      flex: 0 1 1.29rem;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .rightBox {
      padding-top: 10px;
      flex: 1;
      margin-left: 10px;

      div {
        line-height: 0.7rem;
      }

      .t {
        font-size: 16px;

        .time {
          font-size: 13px;
          color: #595959;
          float: right;
          margin-right: 15px;
        }
      }

      .b {
        font-size: 13px;
        color: #595959;
      }
    }
  }
}
</style>




